package com.woniuxy.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniuxy.dto.GoodsPropGroupDto;
import com.woniuxy.entity.GoodsPropgroup;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 属性组 Mapper 接口
 * </p>
 *
 * @author zcx, ftl, gr, rhs
 * @since 2022-01-04
 */
public interface GoodsPropgroupMapper extends BaseMapper<GoodsPropgroup> {
    @Select("SELECT " +
            " t1.*, COUNT(t2.goods_prop_id) AS goods_propgroup_num " +
            "FROM " +
            " `goods_propgroup` t1 " +
            "LEFT JOIN goods_prop t2 ON t1.goods_propgroup_id = t2.goods_propgroup_id " +
            " ${ew.customSqlSegment} " +
            "   GROUP BY " +
            " t1.goods_propgroup_id")
    Page<GoodsPropGroupDto> listGoodsPropGroup(Page<GoodsPropGroupDto> page, @Param(Constants.WRAPPER) QueryWrapper<GoodsPropGroupDto> queryWrapper);
}
